HAL UART state and error functions migration

This section provides information about the HAL UART state and error functions migration.

HAL UART get state

In HAL2, Separate functions are added for specific state machines:
  • HAL_UART_GetTxState() to check the transmission state.

  • HAL_UART_GetRxState() to check the reception state.

HAL1

HAL2

HAL_UART_GetState(UART_HandleTypeDef *huart)
HAL_UART_GetState  (const hal_uart_handle_t *huart)
HAL_UART_GetTxState(const hal_uart_handle_t *huart)
HAL_UART_GetRxState(const hal_uart_handle_t *huart)

Related concepts: Revised and optimized HAL state machine


HAL UART get error

HAL1

HAL2

Description

In HAL1, the function HAL_UART_GetError returns the UART error code. The UART error code can be a combination (bitfields) of the following values:

  • HAL_UART_ERROR_NONE

  • /*

  • HAL_UART_ERROR_PE

  • HAL_UART_ERROR_NE

  • HAL_UART_ERROR_FE

  • HAL_UART_ERROR_ORE

  • HAL_UART_ERROR_RTO

  • HAL_UART_ERROR_DMA

  • /*

  • HAL_UART_ERROR_INVALID_CALLBACK

In HAL2, the function HAL_UART_GetLastErrorCodes retrieves the last error codes for the UART. The UART last error codes can be a combination (bitfields) of the following values:

  • HAL_UART_RECEIVE_ERROR_NONE

  • HAL_UART_TRANSMIT_ERROR_NONE

  • HAL_UART_RECEIVE_ERROR_PE

  • HAL_UART_RECEIVE_ERROR_NE

  • HAL_UART_RECEIVE_ERROR_FE

  • HAL_UART_RECEIVE_ERROR_ORE

  • HAL_UART_RECEIVE_ERROR_RTO

  • HAL_UART_RECEIVE_ERROR_DMA

  • HAL_UART_TRANSMIT_ERROR_DMA

Function name

HAL_UART_GetError(UART_HandleTypeDef *huart);
HAL_UART_GetLastErrorCodes(const hal_uart_handle_t *huart);

Note

In HAL2, the constant HAL_UART_ERROR_INVALID_CALLBACK has been removed. Instead, functions HAL_UART_RegisterXXXCallback() return HAL_INVALID_PARAM in case of an invalid callback pointer.

Related concepts: Revised and optimized HAL error management